home *** CD-ROM | disk | FTP | other *** search
/ Programming a Multiplayer FPS in DirectX / Programming a Multiplayer FPS in DirectX (Companion CD).iso / DirectX / dxsdk_oct2004.exe / dxsdk.exe / Samples / C++ / Direct3D / ConfigSystem / getdxver.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2004-09-28  |  20.7 KB  |  495 lines

  1. //-----------------------------------------------------------------------------
  2. // File: GetDXVer.cpp
  3. //
  4. // Desc: Demonstrates how applications can detect what version of DirectX
  5. //       is installed.
  6. //
  7. // (C) Copyright Microsoft Corp.  All rights reserved.
  8. //-----------------------------------------------------------------------------
  9. #include "dxstdafx.h"
  10. #include <windows.h>
  11. #include <stdio.h>
  12. #include <wchar.h>
  13. #include "ConfigDatabase.h"
  14. #include "ConfigManager.h"
  15. #define INITGUID
  16. #include <guiddef.h>
  17. #include <dxdiag.h>
  18.  
  19.  
  20. HRESULT GetDirectXVersionViaDxDiag( DWORD* pdwDirectXVersionMajor, DWORD* pdwDirectXVersionMinor, WCHAR* pcDirectXVersionLetter );
  21. HRESULT GetDirectXVerionViaFileVersions( DWORD* pdwDirectXVersionMajor, DWORD* pdwDirectXVersionMinor, WCHAR* pcDirectXVersionLetter );
  22. HRESULT GetFileVersion( WCHAR* szPath, ULARGE_INTEGER* pllFileVersion );
  23. ULARGE_INTEGER MakeInt64( WORD a, WORD b, WORD c, WORD d );
  24. int CompareLargeInts( ULARGE_INTEGER ullParam1, ULARGE_INTEGER ullParam2 );
  25.  
  26.  
  27.  
  28.  
  29. //-----------------------------------------------------------------------------
  30. // Name: GetDXVersion()
  31. // Desc: This function returns the DirectX version.
  32. //-----------------------------------------------------------------------------
  33. HRESULT GetDXVersion( DWORD* pdwDirectXVersionMajor, DWORD* pdwDirectXVersionMinor, WCHAR* pcDirectXVersionLetter )
  34. {
  35.     bool bGotDirectXVersion = false;  
  36.  
  37.     // Init values to unknown
  38.     *pdwDirectXVersionMajor = 0;
  39.     *pdwDirectXVersionMinor = 0;
  40.     *pcDirectXVersionLetter = ' ';
  41.  
  42.     // First, try to use dxdiag's COM interface to get the DirectX version.  
  43.     // The only downside is this will only work on DX9 or later.
  44.     if( SUCCEEDED( GetDirectXVersionViaDxDiag( pdwDirectXVersionMajor, pdwDirectXVersionMinor, pcDirectXVersionLetter ) ) )
  45.         bGotDirectXVersion = true;
  46.   
  47.     if( !bGotDirectXVersion )
  48.     {
  49.         // Getting the DirectX version info from DxDiag failed, 
  50.         // so most likely we are on DX8.x or earlier
  51.         if( SUCCEEDED( GetDirectXVerionViaFileVersions( pdwDirectXVersionMajor, pdwDirectXVersionMinor, pcDirectXVersionLetter ) ) )
  52.             bGotDirectXVersion = true;
  53.     }
  54.  
  55.     // If both techniques failed, then return E_FAIL
  56.     if( !bGotDirectXVersion )
  57.         return E_FAIL;
  58.         
  59.     // Set the output values to what we got and return       
  60.     *pcDirectXVersionLetter = (char)tolower(*pcDirectXVersionLetter);
  61.  
  62.    return S_OK;
  63. }
  64.  
  65.  
  66.  
  67.  
  68. //-----------------------------------------------------------------------------
  69. // Name: GetDirectXVersionViaDxDiag()
  70. // Desc: Tries to get the DirectX version from DxDiag's COM interface
  71. //-----------------------------------------------------------------------------
  72. HRESULT GetDirectXVersionViaDxDiag( DWORD* pdwDirectXVersionMajor, 
  73.                                     DWORD* pdwDirectXVersionMinor, 
  74.                                     WCHAR* pcDirectXVersionLetter )
  75. {
  76.     HRESULT hr;
  77.     bool bCleanupCOM = false;
  78.  
  79.     bool bSuccessGettingMajor = false;
  80.     bool bSuccessGettingMinor = false;
  81.     bool bSuccessGettingLetter = false;
  82.     
  83.     // Init COM.  COM may fail if its already been inited with a different 
  84.     // concurrency model.  And if it fails you shouldn't release it.
  85.     hr = CoInitialize(NULL);
  86.     bCleanupCOM = SUCCEEDED(hr);
  87.  
  88.     // Get an IDxDiagProvider
  89.     bool bGotDirectXVersion = false;
  90.     IDxDiagProvider* pDxDiagProvider = NULL;
  91.     hr = CoCreateInstance( CLSID_DxDiagProvider,
  92.                            NULL,
  93.                            CLSCTX_INPROC_SERVER,
  94.                            IID_IDxDiagProvider,
  95.                            (LPVOID*) &pDxDiagProvider );
  96.     if( SUCCEEDED(hr) )
  97.     {
  98.         // Fill out a DXDIAG_INIT_PARAMS struct
  99.         DXDIAG_INIT_PARAMS dxDiagInitParam;
  100.         ZeroMemory( &dxDiagInitParam, sizeof(DXDIAG_INIT_PARAMS) );
  101.         dxDiagInitParam.dwSize                  = sizeof(DXDIAG_INIT_PARAMS);
  102.         dxDiagInitParam.dwDxDiagHeaderVersion   = DXDIAG_DX9_SDK_VERSION;
  103.         dxDiagInitParam.bAllowWHQLChecks        = false;
  104.         dxDiagInitParam.pReserved               = NULL;
  105.  
  106.         // Init the m_pDxDiagProvider
  107.         hr = pDxDiagProvider->Initialize( &dxDiagInitParam ); 
  108.         if( SUCCEEDED(hr) )
  109.         {
  110.             IDxDiagContainer* pDxDiagRoot = NULL;
  111.             IDxDiagContainer* pDxDiagSystemInfo = NULL;
  112.  
  113.             // Get the DxDiag root container
  114.             hr = pDxDiagProvider->GetRootContainer( &pDxDiagRoot );
  115.             if( SUCCEEDED(hr) ) 
  116.             {
  117.                 // Get the object called DxDiag_SystemInfo
  118.                 hr = pDxDiagRoot->GetChildContainer( L"DxDiag_SystemInfo", &pDxDiagSystemInfo );
  119.                 if( SUCCEEDED(hr) )
  120.                 {
  121.                     VARIANT var;
  122.                     VariantInit( &var );
  123.  
  124.                     // Get the "dwDirectXVersionMajor" property
  125.                     hr = pDxDiagSystemInfo->GetProp( L"dwDirectXVersionMajor", &var );
  126.                     if( SUCCEEDED(hr) && var.vt == VT_UI4 )
  127.                     {
  128.                         if( pdwDirectXVersionMajor )
  129.                             *pdwDirectXVersionMajor = var.ulVal; 
  130.                         bSuccessGettingMajor = true;
  131.                     }
  132.                     VariantClear( &var );
  133.  
  134.                     // Get the "dwDirectXVersionMinor" property
  135.                     hr = pDxDiagSystemInfo->GetProp( L"dwDirectXVersionMinor", &var );
  136.                     if( SUCCEEDED(hr) && var.vt == VT_UI4 )
  137.                     {
  138.                         if( pdwDirectXVersionMinor )
  139.                             *pdwDirectXVersionMinor = var.ulVal; 
  140.                         bSuccessGettingMinor = true;
  141.                     }
  142.                     VariantClear( &var );
  143.  
  144.                     // Get the "szDirectXVersionLetter" property
  145.                     hr = pDxDiagSystemInfo->GetProp( L"szDirectXVersionLetter", &var );
  146.                     if( SUCCEEDED(hr) && var.vt == VT_BSTR && SysStringLen( var.bstrVal ) != 0 )
  147.                     {
  148.                         *pcDirectXVersionLetter = var.bstrVal[0];
  149.                         bSuccessGettingLetter = true;
  150.                     }
  151.                     VariantClear( &var );
  152.  
  153.                     // If it all worked right, then mark it down
  154.                     if( bSuccessGettingMajor && bSuccessGettingMinor && bSuccessGettingLetter )
  155.                         bGotDirectXVersion = true;
  156.  
  157.                     pDxDiagSystemInfo->Release();
  158.                 }
  159.  
  160.                 pDxDiagRoot->Release();
  161.             }
  162.         }
  163.  
  164.         pDxDiagProvider->Release();
  165.     }
  166.  
  167.     if( bCleanupCOM )
  168.         CoUninitialize();
  169.         
  170.     if( bGotDirectXVersion )
  171.         return S_OK;
  172.     else
  173.         return E_FAIL;
  174. }
  175.  
  176.  
  177.  
  178.  
  179. //-----------------------------------------------------------------------------
  180. // Name: GetDirectXVerionViaFileVersions()
  181. // Desc: Tries to get the DirectX version by looking at DirectX file versions
  182. //-----------------------------------------------------------------------------
  183. HRESULT GetDirectXVerionViaFileVersions( DWORD* pdwDirectXVersionMajor, 
  184.                                          DWORD* pdwDirectXVersionMinor, 
  185.                                          WCHAR* pcDirectXVersionLetter )
  186. {       
  187.     ULARGE_INTEGER llFileVersion;  
  188.     WCHAR szPath[512];
  189.     WCHAR szFile[512];
  190.     BOOL bFound = false;
  191.  
  192.     if( GetSystemDirectory( szPath, MAX_PATH ) != 0 )
  193.     {
  194.         szPath[MAX_PATH-1]=0;
  195.             
  196.         // Switch off the ddraw version
  197.         wcscpy( szFile, szPath );
  198.         wcscat( szFile, L"\\ddraw.dll" );
  199.         if( SUCCEEDED( GetFileVersion( szFile, &llFileVersion ) ) )
  200.         {
  201.             if( CompareLargeInts( llFileVersion, MakeInt64( 4, 2, 0, 95 ) ) >= 0 ) // Win9x version
  202.             {                    
  203.                 // flle is >= DX1.0 version, so we must be at least DX1.0
  204.                 if( pdwDirectXVersionMajor ) *pdwDirectXVersionMajor = 1;
  205.                 if( pdwDirectXVersionMinor ) *pdwDirectXVersionMinor = 0;
  206.                 if( pcDirectXVersionLetter ) *pcDirectXVersionLetter = L' ';
  207.                 bFound = true;
  208.             }
  209.  
  210.             if( CompareLargeInts( llFileVersion, MakeInt64( 4, 3, 0, 1096 ) ) >= 0 ) // Win9x version
  211.             {                    
  212.                 // flle is is >= DX2.0 version, so we must DX2.0 or DX2.0a (no redist change)
  213.                 if( pdwDirectXVersionMajor ) *pdwDirectXVersionMajor = 2;
  214.                 if( pdwDirectXVersionMinor ) *pdwDirectXVersionMinor = 0;
  215.                 if( pcDirectXVersionLetter ) *pcDirectXVersionLetter = L' ';
  216.                 bFound = true;
  217.             }
  218.  
  219.             if( CompareLargeInts( llFileVersion, MakeInt64( 4, 4, 0, 68 ) ) >= 0 ) // Win9x version
  220.             {                    
  221.                 // flle is is >= DX3.0 version, so we must be at least DX3.0
  222.                 if( pdwDirectXVersionMajor ) *pdwDirectXVersionMajor = 3;
  223.                 if( pdwDirectXVersionMinor ) *pdwDirectXVersionMinor = 0;
  224.                 if( pcDirectXVersionLetter ) *pcDirectXVersionLetter = L' ';
  225.                 bFound = true;
  226.             }
  227.         }
  228.         
  229.         // Switch off the d3drg8x.dll version
  230.         wcscpy( szFile, szPath );
  231.         wcscat( szFile, L"\\d3drg8x.dll" );
  232.         if( SUCCEEDED( GetFileVersion( szFile, &llFileVersion ) ) )
  233.         {
  234.             if( CompareLargeInts( llFileVersion, MakeInt64( 4, 4, 0, 70 ) ) >= 0 ) // Win9x version
  235.             {                    
  236.                 // d3drg8x.dll is the DX3.0a version, so we must be DX3.0a or DX3.0b  (no redist change)
  237.                 if( pdwDirectXVersionMajor ) *pdwDirectXVersionMajor = 3;
  238.                 if( pdwDirectXVersionMinor ) *pdwDirectXVersionMinor = 0;
  239.                 if( pcDirectXVersionLetter ) *pcDirectXVersionLetter = L'a';
  240.                 bFound = true;
  241.             }
  242.         }       
  243.  
  244.         // Switch off the ddraw version
  245.         wcscpy( szFile, szPath );
  246.         wcscat( szFile, L"\\ddraw.dll" );
  247.         if( SUCCEEDED( GetFileVersion( szFile, &llFileVersion ) ) )
  248.         {
  249.             if( CompareLargeInts( llFileVersion, MakeInt64( 4, 5, 0, 155 ) ) >= 0 ) // Win9x version
  250.             {                    
  251.                 // ddraw.dll is the DX5.0 version, so we must be DX5.0 or DX5.2 (no redist change)
  252.                 if( pdwDirectXVersionMajor ) *pdwDirectXVersionMajor = 5;
  253.                 if( pdwDirectXVersionMinor ) *pdwDirectXVersionMinor = 0;
  254.                 if( pcDirectXVersionLetter ) *pcDirectXVersionLetter = L' ';
  255.                 bFound = true;
  256.             }
  257.  
  258.             if( CompareLargeInts( llFileVersion, MakeInt64( 4, 6, 0, 318 ) ) >= 0 ) // Win9x version
  259.             {                    
  260.                 // ddraw.dll is the DX6.0 version, so we must be at least DX6.0
  261.                 if( pdwDirectXVersionMajor ) *pdwDirectXVersionMajor = 6;
  262.                 if( pdwDirectXVersionMinor ) *pdwDirectXVersionMinor = 0;
  263.                 if( pcDirectXVersionLetter ) *pcDirectXVersionLetter = L' ';
  264.                 bFound = true;
  265.             }
  266.  
  267.             if( CompareLargeInts( llFileVersion, MakeInt64( 4, 6, 0, 436 ) ) >= 0 ) // Win9x version
  268.             {                    
  269.                 // ddraw.dll is the DX6.1 version, so we must be at least DX6.1
  270.                 if( pdwDirectXVersionMajor ) *pdwDirectXVersionMajor = 6;
  271.                 if( pdwDirectXVersionMinor ) *pdwDirectXVersionMinor = 1;
  272.                 if( pcDirectXVersionLetter ) *pcDirectXVersionLetter = L' ';
  273.                 bFound = true;
  274.             }
  275.         }
  276.  
  277.         // Switch off the dplayx.dll version
  278.         wcscpy( szFile, szPath );
  279.         wcscat( szFile, L"\\dplayx.dll" );
  280.         if( SUCCEEDED( GetFileVersion( szFile, &llFileVersion ) ) )
  281.         {
  282.             if( CompareLargeInts( llFileVersion, MakeInt64( 4, 6, 3, 518 ) ) >= 0 ) // Win9x version
  283.             {                    
  284.                 // ddraw.dll is the DX6.1 version, so we must be at least DX6.1a
  285.                 if( pdwDirectXVersionMajor ) *pdwDirectXVersionMajor = 6;
  286.                 if( pdwDirectXVersionMinor ) *pdwDirectXVersionMinor = 1;
  287.                 if( pcDirectXVersionLetter ) *pcDirectXVersionLetter = L'a';
  288.                 bFound = true;
  289.             }
  290.         }
  291.  
  292.         // Switch off the ddraw version
  293.         wcscpy( szFile, szPath );
  294.         wcscat( szFile, L"\\ddraw.dll" );
  295.         if( SUCCEEDED( GetFileVersion( szFile, &llFileVersion ) ) )
  296.         {
  297.             if( CompareLargeInts( llFileVersion, MakeInt64( 4, 7, 0, 700 ) ) >= 0 ) // Win9x version
  298.             {                    
  299.                 // TODO: find win2k version
  300.                 
  301.                 // ddraw.dll is the DX7.0 version, so we must be at least DX7.0
  302.                 if( pdwDirectXVersionMajor ) *pdwDirectXVersionMajor = 7;
  303.                 if( pdwDirectXVersionMinor ) *pdwDirectXVersionMinor = 0;
  304.                 if( pcDirectXVersionLetter ) *pcDirectXVersionLetter = L' ';
  305.                 bFound = true;
  306.             }
  307.         }
  308.  
  309.         // Switch off the dinput version
  310.         wcscpy( szFile, szPath );
  311.         wcscat( szFile, L"\\dinput.dll" );
  312.         if( SUCCEEDED( GetFileVersion( szFile, &llFileVersion ) ) )
  313.         {
  314.             if( CompareLargeInts( llFileVersion, MakeInt64( 4, 7, 0, 716 ) ) >= 0 ) // Win9x version
  315.             {                    
  316.                 // ddraw.dll is the DX7.0 version, so we must be at least DX7.0a
  317.                 if( pdwDirectXVersionMajor ) *pdwDirectXVersionMajor = 7;
  318.                 if( pdwDirectXVersionMinor ) *pdwDirectXVersionMinor = 0;
  319.                 if( pcDirectXVersionLetter ) *pcDirectXVersionLetter = L'a';
  320.                 bFound = true;
  321.             }
  322.         }
  323.  
  324.         // Switch off the ddraw version
  325.         wcscpy( szFile, szPath );
  326.         wcscat( szFile, L"\\ddraw.dll" );
  327.         if( SUCCEEDED( GetFileVersion( szFile, &llFileVersion ) ) )
  328.         {
  329.             if( (HIWORD(llFileVersion.HighPart) == 4 && CompareLargeInts( llFileVersion, MakeInt64( 4, 8, 0, 400 ) ) >= 0) || // Win9x version
  330.                 (HIWORD(llFileVersion.HighPart) == 5 && CompareLargeInts( llFileVersion, MakeInt64( 5, 1, 2258, 400 ) ) >= 0) ) // Win2k/WinXP version
  331.             {                    
  332.                 // ddraw.dll is the DX8.0 version, so we must be at least DX8.0 or DX8.0a (no redist change)
  333.                 if( pdwDirectXVersionMajor ) *pdwDirectXVersionMajor = 8;
  334.                 if( pdwDirectXVersionMinor ) *pdwDirectXVersionMinor = 0;
  335.                 if( pcDirectXVersionLetter ) *pcDirectXVersionLetter = L' ';
  336.                 bFound = true;
  337.             }
  338.         }
  339.  
  340.         wcscpy( szFile, szPath );
  341.         wcscat( szFile, L"\\d3d8.dll");
  342.         if( SUCCEEDED( GetFileVersion( szFile, &llFileVersion ) ) )
  343.         {
  344.             if( (HIWORD(llFileVersion.HighPart) == 4 && CompareLargeInts( llFileVersion, MakeInt64( 4, 8, 1, 881 ) ) >= 0) || // Win9x version
  345.                 (HIWORD(llFileVersion.HighPart) == 5 && CompareLargeInts( llFileVersion, MakeInt64( 5, 1, 2600, 881 ) ) >= 0) ) // Win2k/WinXP version
  346.             {                    
  347.                 // d3d8.dll is the DX8.1 version, so we must be at least DX8.1
  348.                 if( pdwDirectXVersionMajor ) *pdwDirectXVersionMajor = 8;
  349.                 if( pdwDirectXVersionMinor ) *pdwDirectXVersionMinor = 1;
  350.                 if( pcDirectXVersionLetter ) *pcDirectXVersionLetter = L' ';
  351.                 bFound = true;
  352.             }
  353.  
  354.             if( (HIWORD(llFileVersion.HighPart) == 4 && CompareLargeInts( llFileVersion, MakeInt64( 4, 8, 1, 901 ) ) >= 0) || // Win9x version
  355.                 (HIWORD(llFileVersion.HighPart) == 5 && CompareLargeInts( llFileVersion, MakeInt64( 5, 1, 2600, 901 ) ) >= 0) ) // Win2k/WinXP version
  356.             {                    
  357.                 // d3d8.dll is the DX8.1a version, so we must be at least DX8.1a
  358.                 if( pdwDirectXVersionMajor ) *pdwDirectXVersionMajor = 8;
  359.                 if( pdwDirectXVersionMinor ) *pdwDirectXVersionMinor = 1;
  360.                 if( pcDirectXVersionLetter ) *pcDirectXVersionLetter = L'a';
  361.                 bFound = true;
  362.             }
  363.         }
  364.  
  365.         wcscpy( szFile, szPath );
  366.         wcscat( szFile, L"\\mpg2splt.ax");
  367.         if( SUCCEEDED( GetFileVersion( szFile, &llFileVersion ) ) )
  368.         {
  369.             if( CompareLargeInts( llFileVersion, MakeInt64( 6, 3, 1, 885 ) ) >= 0 ) // Win9x/Win2k/WinXP version
  370.             {                    
  371.                 // quartz.dll is the DX8.1b version, so we must be at least DX8.1b
  372.                 if( pdwDirectXVersionMajor ) *pdwDirectXVersionMajor = 8;
  373.                 if( pdwDirectXVersionMinor ) *pdwDirectXVersionMinor = 1;
  374.                 if( pcDirectXVersionLetter ) *pcDirectXVersionLetter = L'b';
  375.                 bFound = true;
  376.             }
  377.         }
  378.  
  379.         wcscpy( szFile, szPath );
  380.         wcscat( szFile, L"\\dpnet.dll");
  381.         if( SUCCEEDED( GetFileVersion( szFile, &llFileVersion ) ) )
  382.         {
  383.             if( (HIWORD(llFileVersion.HighPart) == 4 && CompareLargeInts( llFileVersion, MakeInt64( 4, 9, 0, 134 ) ) >= 0) || // Win9x version
  384.                 (HIWORD(llFileVersion.HighPart) == 5 && CompareLargeInts( llFileVersion, MakeInt64( 5, 2, 3677, 134 ) ) >= 0) ) // Win2k/WinXP version
  385.             {                    
  386.                 // dpnet.dll is the DX8.2 version, so we must be at least DX8.2
  387.                 if( pdwDirectXVersionMajor ) *pdwDirectXVersionMajor = 8;
  388.                 if( pdwDirectXVersionMinor ) *pdwDirectXVersionMinor = 2;
  389.                 if( pcDirectXVersionLetter ) *pcDirectXVersionLetter = L' ';
  390.                 bFound = true;
  391.             }
  392.         }
  393.  
  394.         wcscpy( szFile, szPath );
  395.         wcscat( szFile, L"\\d3d9.dll");
  396.         if( SUCCEEDED( GetFileVersion( szFile, &llFileVersion ) ) )
  397.         {
  398.             // File exists, but be at least DX9
  399.             if( pdwDirectXVersionMajor ) *pdwDirectXVersionMajor = 9;
  400.             if( pdwDirectXVersionMinor ) *pdwDirectXVersionMinor = 0;
  401.             if( pcDirectXVersionLetter ) *pcDirectXVersionLetter = L' ';
  402.             bFound = true;
  403.         }
  404.     }
  405.  
  406.     if( !bFound )
  407.     {
  408.         // No DirectX installed
  409.         if( pdwDirectXVersionMajor ) *pdwDirectXVersionMajor = 0;
  410.         if( pdwDirectXVersionMinor ) *pdwDirectXVersionMinor = 0;
  411.         if( pcDirectXVersionLetter ) *pcDirectXVersionLetter = L' ';
  412.     }
  413.  
  414.     return S_OK;
  415. }
  416.  
  417.  
  418.  
  419.  
  420. //-----------------------------------------------------------------------------
  421. // Name: GetFileVersion()
  422. // Desc: Returns ULARGE_INTEGER with a file version of a file, or a failure code.
  423. //-----------------------------------------------------------------------------
  424. HRESULT GetFileVersion( WCHAR* szPath, ULARGE_INTEGER* pllFileVersion )
  425. {   
  426.     if( szPath == NULL || pllFileVersion == NULL )
  427.         return E_INVALIDARG;
  428.  
  429.     DWORD dwHandle;
  430.     UINT  cb;
  431.     cb = GetFileVersionInfoSize( szPath, &dwHandle );
  432.     if (cb > 0)
  433.     {
  434.         BYTE* pFileVersionBuffer = new BYTE[cb];
  435.         if( pFileVersionBuffer == NULL )
  436.             return E_OUTOFMEMORY;
  437.  
  438.         if (GetFileVersionInfo( szPath, 0, cb, pFileVersionBuffer))
  439.         {
  440.             VS_FIXEDFILEINFO* pVersion = NULL;
  441.             if (VerQueryValue(pFileVersionBuffer, L"\\", (VOID**)&pVersion, &cb) && 
  442.                 pVersion != NULL) 
  443.             {
  444.                 pllFileVersion->HighPart = pVersion->dwFileVersionMS;
  445.                 pllFileVersion->LowPart  = pVersion->dwFileVersionLS;
  446.                 delete[] pFileVersionBuffer;
  447.                 return S_OK;
  448.             }
  449.         }
  450.  
  451.         delete[] pFileVersionBuffer;
  452.     }
  453.  
  454.     return E_FAIL;
  455. }
  456.  
  457.  
  458.  
  459.  
  460. //-----------------------------------------------------------------------------
  461. // Name: MakeInt64()
  462. // Desc: Returns a ULARGE_INTEGER where a<<48|b<<32|c<<16|d<<0
  463. //-----------------------------------------------------------------------------
  464. ULARGE_INTEGER MakeInt64( WORD a, WORD b, WORD c, WORD d )
  465. {
  466.     ULARGE_INTEGER ull;
  467.     ull.HighPart = MAKELONG(b,a);
  468.     ull.LowPart = MAKELONG(d,c);
  469.     return ull;
  470. }
  471.  
  472.  
  473.  
  474.  
  475. //-----------------------------------------------------------------------------
  476. // Name: CompareLargeInts()
  477. // Desc: Returns 1 if ullParam1 > ullParam2
  478. //       Returns 0 if ullParam1 = ullParam2
  479. //       Returns -1 if ullParam1 < ullParam2
  480. //-----------------------------------------------------------------------------
  481. int CompareLargeInts( ULARGE_INTEGER ullParam1, ULARGE_INTEGER ullParam2 )
  482. {
  483.     if( ullParam1.HighPart > ullParam2.HighPart )
  484.         return 1;
  485.     if( ullParam1.HighPart < ullParam2.HighPart )
  486.         return -1;
  487.  
  488.     if( ullParam1.LowPart > ullParam2.LowPart )
  489.         return 1;
  490.     if( ullParam1.LowPart < ullParam2.LowPart )
  491.         return -1;
  492.  
  493.     return 0;
  494. }
  495.